<?php
    session_start();
    include 'conecta_bd.php';
    if(empty($_SESSION['usuario']))
    {
        header('Location: index.html');
    }
    
    
        if(($total = mysql_num_rows(mysql_query('SELECT cliente_id FROM cliente WHERE username="'.$_POST['nameUser'].'"'))) > 0){
            header('Location: ../registro.html?m=USRrepe');
        }else if(($total = mysql_num_rows(mysql_query('SELECT cliente_id FROM cliente WHERE email="'.$_POST['email'].'"'))) > 0){
            header('Location: ../registro.html?m=EMArepe'); 
        }else{
             mysql_query("insert into cliente( nombre, ap_pat, ap_mat, email, fecha_nac, username, pwd)
             values('".$_POST['nombre']."','".$_POST['apPat']."','".$_POST['apMat']."','".$_POST['email']."',
             '".$_POST['fecNac']."','".$_POST['nameUser']."','".$_POST['pass']."')");   
             if(mysql_query){
                header('Location: ../index.html?m=registroExito');
             }else{
                echo "Error inesperado No se ha podido registrar nuevo usuario";
                  }
         }       
    
        
?>
